/*
* Universal.h
* Last edited: 21.07.2014
* Author: David Noack
*/
#pragma once
#include "NistTest.h"
#include "math.h"


/**
\class Universal
\brief Implementation of the Maurers Universal-test
*/
class Universal : public NistTest
{

	public:
		/** Construktor
		\param bitArray Represents the random bits which have to be tesed.
		\param bitArraySize The size of bitArry in bits.*/
		Universal(bool* bitArray, int bitArraySize);

		/**Destructor*/
		~Universal(){};

		/** Does nothing*/
		void start(){};

		/**Executes the Universal-test at the bitArray, given by the constructor.
		\param size The number of bits you want to test within the bitArray.*/
		double execute(int size);

	private:
		/** Gets the value of Q,L  and K from value of (number of bits to test)*/
		void analyseInput();
		/** Initialize the table with the Q Blocks */
		void initTable();
		/** Compute the final Table an fn with the K Blocks*/
		void computeFn();
		/**Converts a binary value to a decimal value
		\param Highest bit or length of the block.
		\return The converted decimal value*/
		int binToDec(int hsb);
		/**Helps debuggin*/
		void printTable();
		
		/**known as L from NIST doc*/
		int blocklength;
		/**known as Q from NIST doc*/
		int numberOfInitBlocks; 
		/**known as K from NIST doc*/
		int numberOfTestBlocks; 

		int* table;
		int tableSize;

		static double variance[17];
		static double expectedValue[17];
		double sigma;
		double c;
		double fn;
		double sum;


};

